package com.pcbly.web.components.utils.template.dao;

import java.io.File;

import com.pcbly.web.bean.crm.SysInitSetBean; 

public class SqlCreate {
	public void execute(Class<?> clz) {
		try {
			String pachageString = clz.getPackage().getName();
			String path = pachageString.replaceAll("\\.", "/");
			String pacha = clz.getPackage().getName();
			File file = new File("src/" + path);
			String midTable = pacha.substring(pacha.lastIndexOf(".") + 1, pacha
					.length());
			midTable = "t_" + midTable + "_";
			String tableName;
			if (file.isDirectory()) {
				String[] files = file.list();
				for (String tfile : files) {
					if (tfile.indexOf("java") >= 0) {
						String te = tfile.substring(0, tfile.indexOf("."));
						tableName = midTable + ""
								+ te.substring(0, te.length() - 4);
						tableName = tableName.toLowerCase();
						System.out.println("list.add(\"delete from "+tableName+"\");");
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static void main(String[] args) {
		System.out.println("begin...................");
		SqlCreate dao = new SqlCreate(); 
		dao.execute(SysInitSetBean.class);
		System.out.println("end...................");
	}
}
